package lifecyclemanager.impl;

import topic.Topic;
import lifecyclemanager.CacheInformation;
import lifecyclemanager.CacheLifeCycleManagerListener;

public class CacheLifeCycleManagerListenerImpl implements CacheLifeCycleManagerListener{

	private static CacheLifeCycleManagerListenerImpl cachelifemanager = null; 
	private CacheInformation cacheInfo = null;
	
	private CacheLifeCycleManagerListenerImpl(){
		cacheInfo = new CacheInformationImpl();
	}
	
	public static CacheLifeCycleManagerListenerImpl getInstance(){
		if(cachelifemanager == null)
			cachelifemanager = new CacheLifeCycleManagerListenerImpl();
		return cachelifemanager;
	}
	
	public void notifyCacheCreation(Topic topic, String id) {
		cacheInfo.addEntry(topic, id);
	}

	public void notifyCacheDelete(Topic topic, String id) {
		if(cacheInfo.checkPrivileges(topic))
			cacheInfo.deleteEntry(topic);
	}

}
